<?php
/* * 注意此文档为UTF-8的编码.
 * Created on 2010-6-3
 *
 * @author EXT <isrn@qq.com>
 *
 */
include ('../../includes/global.php');
include ('../global.php');
include ("../power.php");

$treelist = '';
function tree_list($id, $i) {
    global $treelist;
    $temp = Dgs('tree', " parentid='" . $id . "'   and del != '1'");
    if ($temp != '') {
        foreach ($temp as $p) {

            $qq = Dgs('tree', " parentid='" . $p['id'] . "'   and del != '1'");
            if ($qq != '') {
                $treelist[] = array('id' => $p['id'], 'yz' => '0', 'title' => str_repeat('—', $i) . $p['title']);
                $j = $i + 1;
                tree_list($p[id], $j);
            } else {
                $treelist[] = array('id' => $p['id'], 'yz' => '1', 'title' => str_repeat('—', $i) . $p['title']);
            }
        }
    }
}
tree_list(0, 0);

switch ($_REQUEST['op']) {
    /* 	case 'load':{
      ext_request('ok');
      break;}
     */
    case 'add': {
            $tree_id = $_GET['tid'];
            Tr($_GET['tid'], 'tid');
            Tr($_GET['bdtid'], 'bdtid');
            Tr($_GET['bdid'], 'bdid');
            $field = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "tid = $tree_id order by px asc",
//		  'ce'=>1,
                'tn' => "fld"
                    ));
            $tree = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "id = $tree_id",
                'tn' => "tree",
                'limit' => 1
                    ));
            $tname = gettabname($tree['table'], $dbcfg['prefix'], true);
            Tr($tname, 'tname');
            if ($_GET['id']) {
                Tr($_GET['id'], 'id');
                $fdada = Dgd(array(
                    'db' => 'd_sevenel',
                    'cd' => " id = '" . $_GET['id'] . "' and del != '1' ",
                    'tn' => "$tname",
                    'limit' => 1
                        ));
                $temp = json_decode($fdada['cfg'], true);
                foreach ($temp as $key => $value) {
                    Tr($value, $key);
                }
                Tr($fdada, 'tp');
            }
            $rightcfg = array(
                '63' => "<tr>
				<th><font color=red>—用户管理〖63〗</font></th>
				<td class=\"stones\"><input type=\"checkbox\" name=\"xr[63]\"  value='1' " . (($temp['xr'][63]) ? (" checked=true ") : ("")) . " />显示</td>
				<td class=\"u2\"><input type=\"checkbox\"  name=\"r[63]\"  value='1'   " . (($temp['r'][63]) ? (" checked=true ") : ("")) . "  />浏览所有 <input type=\"checkbox\"  name=\"c[63]\"  value='1'  " . (($temp['c'][63]) ? (" checked=true ") : ("")) . "  />添加会员<BR> <input type=\"checkbox\"  name=\"u[63]\"  value='1'  " . (($temp['u'][63]) ? (" checked=true ") : ("")) . "    />修改会员 <input type=\"checkbox\"  name=\"d[63]\"  value='1'   " . (($temp['d'][63]) ? (" checked=true ") : ("")) . "  />删除会员</td>
				<td class=\"crue\"><input type=\"checkbox\"  name=\"b[63]\"  value='1'   " . (($temp['b'][63]) ? (" checked=true ") : ("")) . "   />绑定锁权限<input type=\"checkbox\"  name=\"q[63]\"  value='1'  " . (($temp['q'][63]) ? (" checked=true ") : ("")) . "  />清除锁权限<br><input type=\"checkbox\"  name=\"pz[63]\"  value='1' " . (($temp['pz'][63]) ? (" checked=true ") : ("")) . "  />配置</td>
			   </tr>",
                '64' => "<tr>
				<th><font color=red>—权限模版〖64〗</font></th>
				<td class=\"stones\"><input type=\"checkbox\" name=\"xr[64]\"  value='1'  " . (($temp['xr'][64]) ? (" checked=true ") : ("")) . "   />显示</td>
				<td class=\"u2\"><input type=\"checkbox\"  name=\"r[64]\"  value='1'   " . (($temp['r'][64]) ? (" checked=true ") : ("")) . "   />浏览 <input type=\"checkbox\"  name=\"c[64]\"  value='1'   " . (($temp['c'][64]) ? (" checked=true ") : ("")) . "   />添加<BR> <input type=\"checkbox\"  name=\"u[64]\"  value='1'   " . (($temp['u'][64]) ? (" checked=true ") : ("")) . "    />修改 <input type=\"checkbox\"  name=\"d[64]\"  value='1'   " . (($temp['d'][64]) ? (" checked=true ") : ("")) . "   />删除</td>
				<td class=\"crue\"><input type=\"checkbox\"  name=\"pz[64]\"  value='1' " . (($temp['pz'][64]) ? (" checked=true ") : ("")) . "  />配置</td>
			   </tr>"
            );
            $checkbox = '';
            foreach ($treelist as $value) {

                if (array_key_exists($value['id'], $rightcfg)) {
                    $checkbox.=$rightcfg[$value['id']];
                } else {
                    if ($value['yz']) {
                        $checkbox.="<tr>
					<th>" . $value['title'] . "〖" . $value['id'] . "〗</th>
					<td class=\"stones\"><input type=\"checkbox\" name=\"xr[" . $value['id'] . "]\" onchange=\"smallall(".$value['id'].")\"  value='1'  " . (($temp['xr'][$value['id']]) ? (" checked=true ") : ("")) . "   />显示</td>
					<td class=\"u2\">
                                        <input type=\"checkbox\"  name=\"r[" . $value['id'] . "]\"  value='1' " . (($temp['r'][$value['id']]) ? (" checked=true ") : ("")) . "   />读取 
                                        <input type=\"checkbox\"  name=\"c[" . $value['id'] . "]\"  value='1' " . (($temp['c'][$value['id']]) ? (" checked=true ") : ("")) . "   />写入 
                                        <input type=\"checkbox\"  name=\"u[" . $value['id'] . "]\"  value='1'  " . (($temp['u'][$value['id']]) ? (" checked=true ") : ("")) . "  />修改 
                                        <input type=\"checkbox\"  name=\"d[" . $value['id'] . "]\"  value='1' " . (($temp['d'][$value['id']]) ? (" checked=true ") : ("")) . "  />删除</td>
					<td class=\"crue\"></td>
				   </tr>";
                    } else { $checkbox.="<tr>
					<th>" . $value['title'] . "〖" . $value['id'] . "〗</th>
					<td class=\"stones\"><input type=\"checkbox\"  name=\"xr[" . $value['id'] . "]\"  value='1'  " . (($temp['xr'][$value['id']]) ? (" checked=true ") : ("")) . "   />显示</td>
					<td class=\"u2\"></td>
					<td class=\"crue\"></td>
				   </tr>"; } }
            }
            $checkbox.="<tr>
					<th><font color=green>CMS配置</font></th>
					<td class=\"stones\"></td>
					<td class=\"u2\"><input type=\"checkbox\"  name=\"xt[1]\"  value='1'   " . (($temp['xt'][1]) ? (" checked=true ") : ("")) . "  />菜单配置<input type=\"checkbox\"  name=\"xt[2]\"  value='1'   " . (($temp['xt'][2]) ? (" checked=true ") : ("")) . "  />数据配置<BR> <input type=\"checkbox\"  name=\"xt[3]\"  value='1'   " . (($temp['xt'][3]) ? (" checked=true ") : ("")) . "  />表单配置<input type=\"checkbox\"  name=\"xt[4]\"  value='1'   " . (($temp['xt'][4]) ? (" checked=true ") : ("")) . "  />用户管理<br>
<input type=\"checkbox\"  name=\"xt[5]\"  value='1'   " . (($temp['xt'][5]) ? (" checked=true ") : ("")) . "  />权限分配</td>
				<td class=\"crue\"><input type=\"checkbox\"  name=\"xt[6]\"  value='1'   " . (($temp['xt'][6]) ? (" checked=true ") : ("")) . "  />模块配置<input type=\"checkbox\"  name=\"xt[7]\"  value='1'   " . (($temp['xt'][7]) ? (" checked=true ") : ("")) . "  />程序源管理<br><input type=\"checkbox\"  name=\"xt[8]\"  value='1'   " . (($temp['xt'][8]) ? (" checked=true ") : ("")) . "  />模版管理<input type=\"checkbox\"  name=\"xt[9]\"  value='1'   " . (($temp['xt'][9]) ? (" checked=true ") : ("")) . "  />插件管理<br><input type=\"checkbox\"  name=\"xt[10]\"  value='1'   " . (($temp['xt'][10]) ? (" checked=true ") : ("")) . "  />系统管理</td>
			   </tr>";
            Tr($checkbox, 'tr');


            Ts('right/add.html');
            break; }

    case 'right_assign':
            Ts('right/right_assign.html');
        break;
    default: {
            Ts('right/index.html');
            break;
        }
}
?>
